package huawei;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 观看文艺表演问题
 */
public class Q116 {


    public static void main(String[] args) {

        String[] strings = {"720 120", "840 120", "974 1000"};

        List<int[]> list = new ArrayList<>();
        for (String s : strings) {
            List<Integer> collect = Arrays.stream(s.split(" ")).map(String::trim).map(Integer::parseInt).collect(Collectors.toList());
            list.add(new int[]{collect.get(0), collect.get(0) + collect.get(1)});
        }

        list.sort(Comparator.comparingInt(e -> e[1]));

        System.out.println(list);

        int count = 0;
        int end = -15;
        for (int[] ints : list) {
            if (ints[0] >= end + 15) {
                count++;
                end = ints[1];
            }
        }

        System.out.println(count);
    }
}
